let usernameELe = document.getElementsByClassName('username')[0]
let passwordELe = document.getElementsByClassName('password')[0]
let rePasswordELe = document.getElementsByClassName('re-password')[0]
let ageELe = document.getElementsByClassName('age')[0]
let genderELe = document.getElementsByClassName('gender')[0]
let btnELe = document.getElementsByClassName('btn')[0]

btnELe.onclick = ()=>{
  if(usernameELe.value&&passwordELe.value&&rePasswordELe.value&&ageELe.value&&genderELe.value){
    $.ajax({
      type:'post',
      url:'http://localhost:3000/user/userRegist',
      data:{
        username:usernameELe.value,
        password:passwordELe.value,
        rePassword:rePasswordELe.value,
        age:ageELe.value,
        gender:genderELe.value
      },
      success:(result)=>{
        
        if(result.status === 'failed'){
        
          alert(result.message)
        }else{
          location.href='/user/login'
        }
      }
    })
  }
  
}